

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>开发者指南（快速） &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="RADOS 客户端协议" href="../rados-client-protocol/" />
    <link rel="prev" title="PG （归置组）说明" href="../placement-group/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../internals/">Ceph 内幕</a> &raquo;</li>
        
      <li>开发者指南（快速）</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/dev/quick_guide.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../">
          

          
            
            <img src="../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../developer_guide/">开发者指南</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../internals/">Ceph 内幕</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../blkin/">Tracing Ceph With LTTng</a></li>
<li class="toctree-l2"><a class="reference internal" href="../blkin/#tracing-ceph-with-blkin">Tracing Ceph With Blkin</a></li>
<li class="toctree-l2"><a class="reference internal" href="../bluestore/">BlueStore Internals</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cache-pool/">Cache pool</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ceph_krb_auth/">如何配置好 Ceph Kerberos 认证的详细文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephfs-mirroring/">CephFS Mirroring</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephfs-reclaim/">CephFS Reclaim Interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephfs-snapshots/">CephFS 快照</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephx/">Cephx</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephx_protocol/">Cephx 认证协议详细阐述</a></li>
<li class="toctree-l2"><a class="reference internal" href="../config/">配置管理系统</a></li>
<li class="toctree-l2"><a class="reference internal" href="../config-key/">config-key layout</a></li>
<li class="toctree-l2"><a class="reference internal" href="../context/">CephContext</a></li>
<li class="toctree-l2"><a class="reference internal" href="../continuous-integration/">Continuous Integration Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../corpus/">资料库结构</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cpu-profiler/">Oprofile 的安装</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cxx/">C++17 and libstdc++ ABI</a></li>
<li class="toctree-l2"><a class="reference internal" href="../deduplication/">去重</a></li>
<li class="toctree-l2"><a class="reference internal" href="../delayed-delete/">CephFS delayed deletion</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dev_cluster_deployement/">开发集群的部署</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dev_cluster_deployement/#id5">在同一机器上部署多套开发集群</a></li>
<li class="toctree-l2"><a class="reference internal" href="../development-workflow/">开发流程</a></li>
<li class="toctree-l2"><a class="reference internal" href="../documenting/">为 Ceph 写作文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../encoding/">序列化（编码、解码）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../erasure-coded-pool/">纠删码存储池</a></li>
<li class="toctree-l2"><a class="reference internal" href="../file-striping/">File striping</a></li>
<li class="toctree-l2"><a class="reference internal" href="../freebsd/">FreeBSD Implementation details</a></li>
<li class="toctree-l2"><a class="reference internal" href="../generatedocs/">Ceph 文档的构建</a></li>
<li class="toctree-l2"><a class="reference internal" href="../health-reports/">Health Reports</a></li>
<li class="toctree-l2"><a class="reference internal" href="../iana/">IANA 号</a></li>
<li class="toctree-l2"><a class="reference internal" href="../kubernetes/">Hacking on Ceph in Kubernetes with Rook</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libs/">库体系结构</a></li>
<li class="toctree-l2"><a class="reference internal" href="../logging/">集群日志的用法</a></li>
<li class="toctree-l2"><a class="reference internal" href="../logs/">调试日志</a></li>
<li class="toctree-l2"><a class="reference internal" href="../macos/">在 MacOS 上构建</a></li>
<li class="toctree-l2"><a class="reference internal" href="../messenger/">Messenger notes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-bootstrap/">Monitor bootstrap</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-elections/">Monitor Elections</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-on-disk-formats/">ON-DISK FORMAT</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-osdmap-prune/">FULL OSDMAP VERSION PRUNING</a></li>
<li class="toctree-l2"><a class="reference internal" href="../msgr2/">msgr2 协议（ msgr2.0 和 msgr2.1 ）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../network-encoding/">Network Encoding</a></li>
<li class="toctree-l2"><a class="reference internal" href="../network-protocol/">网络协议</a></li>
<li class="toctree-l2"><a class="reference internal" href="../object-store/">对象存储架构概述</a></li>
<li class="toctree-l2"><a class="reference internal" href="../osd-class-path/">OSD class path issues</a></li>
<li class="toctree-l2"><a class="reference internal" href="../peering/">互联</a></li>
<li class="toctree-l2"><a class="reference internal" href="../perf/">Using perf</a></li>
<li class="toctree-l2"><a class="reference internal" href="../perf_counters/">性能计数器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../perf_histograms/">Perf histograms</a></li>
<li class="toctree-l2"><a class="reference internal" href="../placement-group/">PG （归置组）说明</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">开发者指南（快速）</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id2">开发</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id3">开发集群的部署</a></li>
<li class="toctree-l3"><a class="reference internal" href="#vstart">vstart 环境的重置</a></li>
<li class="toctree-l3"><a class="reference internal" href="#radosgw">部署 RadosGW 开发环境</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id4">运行单元测试</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../rados-client-protocol/">RADOS 客户端协议</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-diff/">RBD 增量备份</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-export/">RBD Export &amp; Import</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-layering/">RBD Layering</a></li>
<li class="toctree-l2"><a class="reference internal" href="../release-checklists/">Release checklists</a></li>
<li class="toctree-l2"><a class="reference internal" href="../release-process/">Ceph Release Process</a></li>
<li class="toctree-l2"><a class="reference internal" href="../seastore/">SeaStore</a></li>
<li class="toctree-l2"><a class="reference internal" href="../sepia/">Sepia 社区测试实验室</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session_authentication/">Session Authentication for the Cephx Protocol</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/">测试笔记</a></li>
<li class="toctree-l2"><a class="reference internal" href="../versions/">Public OSD Version</a></li>
<li class="toctree-l2"><a class="reference internal" href="../vstart-ganesha/">NFS CephFS-RGW Developer Guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../wireshark/">Wireshark Dissector</a></li>
<li class="toctree-l2"><a class="reference internal" href="../zoned-storage/">Zoned Storage Support</a></li>
<li class="toctree-l2"><a class="reference internal" href="../osd_internals/">OSD 开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mds_internals/">MDS 开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../radosgw/">RADOS 网关开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ceph-volume/">ceph-volume 开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../crimson/">Crimson developer documentation</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="id1">
<h1>开发者指南（快速）<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h1>
<p>本指南将解说如何构建并测试用于开发的 Ceph 。</p>
<div class="section" id="id2">
<h2>开发<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">run-make-check.sh</span></code> 脚本会安装 Ceph 依赖，一切都在调试模式下编译、并进行一系列测试，以验证结果正如所需。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt1:before {
  content: "$ ";
}
</style><span class="prompt1">./run-make-check.sh</span>
</pre></div></div><p>如果你只想选择性地开发某个 Ceph 组件，
安装好依赖关系并用必需的 cmake 标识构建调试模式的 Ceph 。</p>
<p>实例：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">./install-deps.sh</span>
<span class="prompt1">./do_cmake.sh -DWITH_MANPAGE<span class="o">=</span>OFF -DWITH_BABELTRACE<span class="o">=</span>OFF -DWITH_MGR_DASHBOARD_FRONTEND<span class="o">=</span>OFF</span>
</pre></div></div><p>你也可以取消构建那些与开发无关的核心组件：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">./do_cmake.sh ... -DWITH_RBD<span class="o">=</span>OFF -DWITH_KRBD<span class="o">=</span>OFF -DWITH_RADOSGW<span class="o">=</span>OFF</span>
</pre></div></div><p>最后，构建 ceph ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">cmake --build build <span class="o">[</span>--target &lt;target&gt;...<span class="o">]</span></span>
</pre></div></div><p>如果你想完整地构建，忽略 <code class="docutils literal notranslate"><span class="pre">--target...</span></code> 即可。</p>
</div>
<div class="section" id="id3">
<h2>开发集群的部署<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<p>Ceph 包含一个名为 <code class="docutils literal notranslate"><span class="pre">vstart.sh</span></code> 的脚本（还有<a class="reference internal" href="../dev_cluster_deployement/"><span class="doc">开发集群的部署</span></a>），可以让开发者们在开发系统上用最简部署快速地测试代码。编译成功后，用下列命令开始部署：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1"><span class="nb">cd</span> build</span>
<span class="prompt1">../src/vstart.sh -d -n</span>
</pre></div></div><p>你也可以让 <code class="docutils literal notranslate"><span class="pre">vstart.sh</span></code> 只用一个监视器和一个元数据服务器，
用下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">env <span class="nv">MON</span><span class="o">=</span><span class="m">1</span> <span class="nv">MDS</span><span class="o">=</span><span class="m">1</span> ../src/vstart.sh -d -n -x</span>
</pre></div></div><p>集群的大多数日志都位于 <code class="docutils literal notranslate"><span class="pre">build/out</span></code> 。</p>
<p>这个系统启动时创建了两个存储池： <cite>cephfs_data_a</cite> 和
<cite>cephfs_metadata_a</cite> ，我们看看当前存储池的统计信息：</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>bin/ceph osd pool stats
<span class="go">*** DEVELOPER MODE: setting PATH, PYTHONPATH and LD_LIBRARY_PATH ***</span>
<span class="go">pool cephfs_data_a id 1</span>
<span class="go">  nothing is going on</span>

<span class="go">pool cephfs_metadata_a id 2</span>
<span class="go">  nothing is going on</span>

<span class="gp">$ </span>bin/ceph osd pool stats cephfs_data_a
<span class="go">*** DEVELOPER MODE: setting PATH, PYTHONPATH and LD_LIBRARY_PATH ***</span>
<span class="go">pool cephfs_data_a id 1</span>
<span class="go">  nothing is going on</span>

<span class="gp">$ </span>bin/rados df
<span class="go">POOL_NAME         USED OBJECTS CLONES COPIES MISSING_ON_PRIMARY UNFOUND DEGRADED RD_OPS RD WR_OPS WR</span>
<span class="go">cephfs_data_a        0       0      0      0                  0       0        0      0  0      0    0</span>
<span class="go">cephfs_metadata_a 2246      21      0     63                  0       0        0      0  0     42 8192</span>

<span class="go">total_objects    21</span>
<span class="go">total_used       244G</span>
<span class="go">total_space      1180G</span>
</pre></div>
</div>
<p>创建个存储池，并给它做个压力测试：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">bin/ceph osd pool create mypool</span>
<span class="prompt1">bin/rados -p mypool bench <span class="m">10</span> write -b <span class="m">123</span></span>
</pre></div></div><p>放一个文件到新存储池里：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">bin/rados -p mypool put objectone &lt;somefile&gt;</span>
<span class="prompt1">bin/rados -p mypool put objecttwo &lt;anotherfile&gt;</span>
</pre></div></div><p>罗列存储池内的对象：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">bin/rados -p mypool ls</span>
</pre></div></div><p>工作结束后，可以用下面的停止 Ceph 开发环境：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">../src/stop.sh</span>
</pre></div></div></div>
<div class="section" id="vstart">
<h2>vstart 环境的重置<a class="headerlink" href="#vstart" title="Permalink to this headline">¶</a></h2>
<p>vstart 脚本会创建 out/ 和 dev/ 目录，集群的状态就保存在里面。如果你想快速重置环境，也许可以这样：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt2:before {
  content: "[build]$ ";
}
</style><span class="prompt2">../src/stop.sh</span>
<span class="prompt2">rm -rf out dev</span>
<span class="prompt2">env <span class="nv">MDS</span><span class="o">=</span><span class="m">1</span> <span class="nv">MON</span><span class="o">=</span><span class="m">1</span> <span class="nv">OSD</span><span class="o">=</span><span class="m">3</span> ../src/vstart.sh -n -d</span>
</pre></div></div></div>
<div class="section" id="radosgw">
<h2>部署 RadosGW 开发环境<a class="headerlink" href="#radosgw" title="Permalink to this headline">¶</a></h2>
<p>运行 vstart.sh 时设置 <code class="docutils literal notranslate"><span class="pre">RGW</span></code> 变量即可启用 RadosGW 。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1"><span class="nb">cd</span> build</span>
<span class="prompt1"><span class="nv">RGW</span><span class="o">=</span><span class="m">1</span> ../src/vstart.sh -d -n -x</span>
</pre></div></div><p>现在你可以用 swift python 客户端与 RadosGW 通讯了。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1">swift -A http://localhost:8000/auth -U test:tester -K testing list</span>
<span class="prompt1">swift -A http://localhost:8000/auth -U test:tester -K testing upload mycontainer ceph</span>
<span class="prompt1">swift -A http://localhost:8000/auth -U test:tester -K testing list</span>
</pre></div></div></div>
<div class="section" id="id4">
<h2>运行单元测试<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h2>
<p>测试代码位于 <cite>src/tests</cite> ，可以这样运行：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span class="prompt1"><span class="o">(</span><span class="nb">cd</span> build <span class="o">&amp;&amp;</span> ninja check<span class="o">)</span></span>
</pre></div></div></div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../rados-client-protocol/" class="btn btn-neutral float-right" title="RADOS 客户端协议" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../placement-group/" class="btn btn-neutral float-left" title="PG （归置组）说明" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>